package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.ZCfunds;
import com.hbnu.system.service.ZCfundsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ZCfunds")
@Api(tags = "横向支出经费相关模块")
public class ZCfundsController {
    @Autowired
    ZCfundsService zcfundsService;

    @ApiOperation("支出经费添加")
    @PostMapping("/addZCfunds")
    public Rest<Boolean> AddZCfunds(@RequestBody ZCfunds zcfunds){
        boolean add = zcfundsService.addZCfundsProject(zcfunds);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("支出经费删除")
    @GetMapping("/removeZCfunds")
    public Rest<Boolean> RemoveZCfunds(String id){
        boolean remove= zcfundsService.removeZCfundsProject(id);
        return remove ? Rest.success() : Rest.failed();
    }
    @ApiOperation("支出经费更新")
    @PostMapping("/UpdateZCfunds")
    public Rest<Boolean> UpdateZCfunds(@RequestBody ZCfunds zcfunds){
        boolean update = zcfundsService.updateZCfundsProject(zcfunds);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("支出经费-通过横向项目id查询")
    @GetMapping("/GetZCfundsByTranprojectID")
    public Rest<List<ZCfunds>> GetZCfundsByTranprojectID(String tranID){
        List<ZCfunds> paperProjectByPaperID = zcfundsService.getZCfundsByTranprojectID(tranID);
        return Rest.success(paperProjectByPaperID);
    }
}
